/*
 * @Description:
 * @Version: 1.0
 * @Author: Ausen
 * @Date: 2023-03-27 17:20:28
 * @LastEditors: Ausen
 * @LastEditTime: 2025-01-12 16:16:28
 */
/*  -------------------------- (C) COPYRIGHT 2022 Fortiortech ShenZhen ---------------------------*/
/**
 * @copyright (C) COPYRIGHT 2022 Fortiortech Shenzhen
 * @file      LED.c
 * @author    Fortiortech  Appliction Team
 * @since     Create:2022-07-14
 * @date      Last modify:2022-07-14
 * @note      Last modify author is Leo.li
 * @brief
 */

/* Define to prevent recursive inclusion --------------------------------------------------------*/
#ifndef __EXTIINIT_H_
#define __EXTIINIT_H_

typedef struct
{
    uint8 ScrOnAngleTimeDatum; // 期望给定 导通延迟时间  单位为  1/载波频率
//    uint8 ScrOnAngleTime_L;    // 实际给定 导通延迟时间  单位为  1/载波频率
    int8 ScrOnAngleTime;       // 实际给定 导通延迟时间  单位为  1/载波频率
//    uint8 ScrOnAngleTime_V;    // 实际给定 导通延迟时间  单位为  1/载波频率
    uint8 ScrOnPeriod;         // 控制周期
    uint16 Temperature;        // 温度值
    // float AverageVoltageValue; // 平均电压，DC直流值
    uint16 TPCtrlDealy;        // 发热丝导通延时计数
    uint16 ScrOnTime;          // 发热丝开关计数

//    int8 VoltageScrOnAngleTime; // 电压功率平衡voltage balance
//    uint16 VoltageScrOnAngleTimeSum;
//    uint8 VoltageScrOnAngleTimeAvg;
//    uint8 VoltageScrOnAngleTimeCnt;
//    uint8 VoltageScrOnAngleTimeAvgOld;
//    uint8 VoltageScrOnAngleTimeAvgChangeFlag;

    uint8 tCnt; // 过热保护，over heat
    uint8 overtCnt;
    uint32 TemperatureSum;
    uint16 TemperatureAverage;
    uint8 overHeatFlag;
    uint8 overedCnt;
    uint8 HeatFlag;

//    int32 et_sum; // NTCTempAdjust
//    int16 et_avg; // NTCTempAdjust
//    int16 et_before;
//    int16 et_now;
   int16 targetTempAD;
//    uint16 etCnt;
//    uint8 NTCScrOnAngleTimeAvg;
//    uint8 NTCScrOnAngleTimeAvgOld;
//    uint8 NTCScrOnAngleTimeAvgChangeFlag;

    uint8 tempCnt;    // 发热丝延迟关闭
    uint8 tempOnFlag; // 发热丝开启标识
    uint8 tempCycle;  // 发热丝开关控制周期
    uint8 tempDt;     // 发

    uint8 ScrOnAngleChange;

    uint16 ntcFaultCnt; // NTCFault
    uint8 ntcFaultFlag;
    uint8 ntcFaultChange;

    uint8 VoltageScrOnAngleChangeFlag;
    uint8 TempPercent;
    uint8 commDivisor;
    float AverageVoltageValue;    // 平均电压，DC直流值
    float AverageVoltageValuePre; // 平均电压，DC直流值
    float ScrOnAngleRatioK1;
    // float ScrOnAngleRatioK2;
    float ScrOnAngleRatioK; // 电压修正系数
    uint8 VoltageScrOnAngleTimeAvg;

} USER_TYPEDEF;

/* Exported variables ---------------------------------------------------------------------------*/
extern USER_TYPEDEF User;

/* Exported functions ---------------------------------------------------------------------------*/
extern void EXTI_Init(void);
extern void Sleepmode_Init(void);
extern void ZeroCrossing_Init(void);

#endif
